package org.mics.cyy.modular.notice.controller;

import java.util.List;

import javax.annotation.Resource;

import org.mics.core.page.PageQuery;
import org.mics.core.response.MultipleDataResponse;
import org.mics.core.response.OneDataResponse;
import org.mics.core.response.PageDataResponse;
import org.mics.core.response.SimpleResponse;
import org.mics.cyy.modular.notice.entity.NoticeTypeDO;
import org.mics.cyy.modular.notice.request.NoticeTypeRequest;
import org.mics.cyy.modular.notice.service.NoticeTypeService;
import org.mics.cyy.modular.notice.vo.NoticeTypeVO;
import org.mics.lang.bean.BeanConvertUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 公告类型
 * @author mics
 * @date 2023-10-10
 * @version  1.0
 */
@RestController
@RequestMapping("/noticeType")
@Tag(name = "公告类型")
public class NoticeTypeController {
	@Resource
	private NoticeTypeService noticeTypeService;
	
	@Operation(summary =  "增加/修改公告类型")
    @RequestMapping(value = "/save",method = RequestMethod.POST)
	public SimpleResponse save(@Validated @RequestBody NoticeTypeRequest noticeTypeRequest ) {
		String id =   noticeTypeService.save(noticeTypeRequest);
		return new OneDataResponse<String>(id);
	}
	
	@Operation(summary =  "删除公告类型")
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.DELETE)
	public SimpleResponse delete(@PathVariable("id") String id) {
		noticeTypeService.delete(id);
        return new SimpleResponse();
	}
	
	@Operation(summary =  "公告类型分页列表")
    @RequestMapping(value = "/listByPage",method = RequestMethod.POST)
	public PageDataResponse<NoticeTypeVO> listByPage(@RequestBody PageQuery pageQuery) {
		PageDataResponse<NoticeTypeVO> pageDataResponse =   noticeTypeService.listByPage(pageQuery);
		return pageDataResponse;
	}
	
	@Operation(summary =  "公告类型列表")
    @RequestMapping(value = "/list",method = RequestMethod.GET)
	public MultipleDataResponse<NoticeTypeVO> list() {
		List<NoticeTypeDO>  noticeTypeDOs =  noticeTypeService.list();
        return new MultipleDataResponse<NoticeTypeVO>(BeanConvertUtil.convertList(noticeTypeDOs, NoticeTypeVO.class));
	}
}
